package cn.wzx.controller;

import cn.wzx.entity.User;
import cn.wzx.service.UserService;
import cn.wzx.util.RespJson;
import cn.wzx.util.SessionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    //获取添加表单
    @RequestMapping("/go2Add")
    public String go2Add(){
        return "user/add";
    }

    @ResponseBody
    @RequestMapping("/add")
    public Map<String, Object> add(@RequestBody User user){  //添加用户 绑定User对象
        userService.addUser(user);
        return RespJson.pack(200,"注册成功",null);
    }
}
